#include<iostream>
using namespace std;

class complex{
    public:
    complex(int real,int image)
    :_real(real)
    ,_image(image)
    {}
    void print () const
    {
        cout << _real <<"+" << _image <<"i" << endl;
    }

    friend complex operator +(const complex &rhs,const complex &lhs);
  
    private:
    int _real;
    int _image;
};

//当我要写一个函数时要考虑要对什么进行操作，操作的参数是什么，返回值是什么,
//为普通函数不可以访问类的私有成员，将函数在类中声明为友元
complex operator +(const complex &rhs,const complex &lhs)
{
    return complex(rhs._real + lhs._real,rhs._image+lhs._image);
}

void test0()
{
    complex c1(2,3);
    complex c2(3,5);
    //会调用默认的拷贝构造
    complex c3 = c1 + c2;
    c3.print();

}
int main()
{
    test0();
    return 0;
}